#coding:utf-8
import csv
import re

csvfile = file('stock.csv', 'rb')
reader = csv.reader(csvfile)
res = []
result = []
re_file = []

for line in reader:
    res = re.split(',', str(line))
    re_file.append(res[0] + ',')
    st = re.split('"', res[1])
    if st[0] in result:
	st[0] = "'***'" + st[0]
    result.append(st[0] )
    re_file.append(st[0] + ',' + res[2] + '\n')

csvfile.close() 

result_file = open('result_file.csv', 'w')
for line in re_file:
    line = line.replace('"', '')
    line = line.replace("'", "")
    line = line.replace('[', '')
    line = line.replace(']', '')
    result_file.writelines(line)
